'use strict';

const path = require('path');
const root = path.resolve(__dirname, '..');
const build = path.join(root, 'dist', 'styles.css');
const dest = path.join(root, 'dist');
const ext = '.min.css';

/**
 * Minify css.
 *
 * @method cssmin
 */
function cssmin(gulp, plugins) {
  return () => gulp.src(build)
    .pipe(plugins.plumber({ errorHandler: (err) => plugins.util.log('[cssmin]', err) }))
    .pipe(plugins.cssnano())
    .pipe(plugins.rename({ extname: ext }))
    .pipe(plugins.debug({ title: 'minified into:' }))
    .pipe(gulp.dest(dest))
  ;
}
module.exports = cssmin;
